Skip to content

fix: add timeout to AppInsights flush to prevent blocking process exit#1532

Open
ameyjain wants to merge 1 commit intomainfrom
fix/appinsights-flush-timeout
Open

fix: add timeout to AppInsights flush to prevent blocking process exit#1532
ameyjain wants to merge 1 commit intomainfrom
fix/appinsights-flush-timeout

Conversation

@ameyjain
Copy link
Copy Markdown
Contributor

@ameyjain ameyjain commented Mar 31, 2026

Summary

  • AppInsights flush() now runs in a daemon=True thread with a 5s timeout
  • If the Azure endpoint is unreachable (e.g. Automation Suite / CI with restricted egress), the flush is abandoned after 5s instead of blocking indefinitely
  • Bumps uipath version to 2.10.40

Problem

In Automation Suite environments, coded agent eval runs were getting stuck in Running state forever. The root cause:

  1. The Python process completes the eval (PUT to update eval run succeeds)
  2. AppInsightsEventClient.flush() is called (via finally block or atexit handler)
  3. AS/CI environments block outbound access to dc.applicationinsights.azure.com
  4. urlopen() times out → _DiagnosticSender re-queues the items → SynchronousQueue.flush() retries in a loop
  5. Process never exits → Orchestrator never receives the exit signal → job stays "Running"

Alpha works fine because it has outbound internet access and the flush completes in <1s.

Fix

thread = threading.Thread(target=_do_flush, daemon=True)
thread.start()
thread.join(timeout=timeout)  # default 5s
if thread.is_alive():
    _logger.warning("AppInsights flush: timed out after %.1fs, abandoning send", timeout)

Using daemon=True ensures the thread is abandoned on process exit even if join() somehow doesn't return in time.

Test plan

  • Existing flush tests pass (8 passed)
  • Verify eval runs complete in AS/CI environments (no longer stuck in Running)
  • Verify alpha behaviour unchanged (flush completes within 5s, no timeout warning)

@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Mar 31, 2026
@ameyjain ameyjain marked this pull request as ready for review March 31, 2026 18:39
@ameyjain ameyjain force-pushed the fix/appinsights-flush-timeout branch 4 times, most recently from 06c551d to c9c13ad Compare March 31, 2026 19:49
Run flush in a daemon thread with a 5s timeout so AppInsights telemetry
never blocks process exit when the Azure endpoint is unreachable (e.g.
Automation Suite / CI environments with restricted egress).

Previously the synchronous flush blocked indefinitely on URLError retries,
keeping the process alive and leaving eval runs stuck in "Running" state.
@ameyjain ameyjain force-pushed the fix/appinsights-flush-timeout branch from c9c13ad to 604cd34 Compare March 31, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant